using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using System.Xml.Serialization;
using XnaUtility.AI.FSM;
using XnaUtility.UI;

namespace XnaUtility.ScreenManagement
{
    public abstract class ScreenState : FSM_State
    {
        public abstract void Draw(GameTime gameTime, SpriteBatch spriteBatch);

        public ScreenState(IBrain newBrain)
            : base(newBrain)
        {
        }

        public bool canDraw;
        public bool canUpdate;
        public bool canGetInput;

        public int targetState;
        public Texture2D background = null;
        
        

        public ScreenBrain scrnBrain;
        public List<UI_Element> uiElements;

        /// <summary>
        /// The purpose of this function is to see if any UI elements were acted on.
        /// By default, it checks for a mouse click, and stops looking after finding one
        /// clicked on element
        /// </summary>
        /// <returns>Returns false if no elements were acted on, true if an element was acted on</returns>
        public virtual bool CheckInput()
        {
            bool result = false;

            Point target;           
            target.X = (int)scrnBrain.input.MousePosition.X;
            target.Y = (int)scrnBrain.input.MousePosition.Y;

            foreach (UI_Element element in uiElements)
            {
                //if (result = element.WasClicked(target)) break;
            }

            return result;
        }


        public override void Init()
        {
            canDraw = false;
            canUpdate = false;
            canGetInput = false;
        }

        public void TurnOn()
        {
            canDraw = true;
            canUpdate = true;
            canGetInput = true;
        }

        public void TurnOff()
        {
            canDraw = false;
            canUpdate = false;
            canGetInput = false;
        }
    }
}

